home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT49.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.4 KB  |  77 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 49                         
  5.                                                                               
  6.  This program will show how to use the wfade_between and wfade_between_once  
  7.  commands. It will fade an image between the default palette and the image   
  8.  palette.                                                                    
  9.                                                                               
  10.  *** PROJECT ***                                                             
  11.  This program requires the WGT5_WC.LIB file to be linked.                    
  12.                                                                               
  13.  *** DATA FILES ***                                                          
  14.  WGT1.PCX must be in the executable directory.                  
  15.                                                            WATCOM C++ VERSION 
  16. ==============================================================================
  17. */
  18.  
  19. #include <stdlib.h>
  20. #include <conio.h>
  21. #include <wgt5.h>
  22.  
  23. void main (void)
  24. {
  25.   block myimage;                        /* Pointer to loaded image */
  26.   color desired[256];                   /* Image palette */
  27.   color defaultpal[256];                /* First copy of default palette */
  28.   color backup_pal[256];                /* Second copy of default palette */
  29.   short oldmode;                          /* Initial video mode */
  30.   short ctr;                              /* Loop counter */
  31.  
  32.   if ( !vgadetected () )
  33.   {
  34.     printf ("Error - VGA card required for any WGT program.\n");
  35.     exit (0);
  36.   }
  37.   printf ("WGT Example #49\n\n");
  38.   printf ("The WFADE_BETWEEN command is demonstrated by fading from the default palette\n");
  39.   printf ("to the image palette. Press a key to use the WFADE_BETWEEN_ONCE command so\n");
  40.   printf ("that processing can be done while the fade is being performed.\n");
  41.   printf ("\n\nPress any key to continue.\n");
  42.   getch();
  43.  
  44.  
  45.   oldmode = wgetmode ();                 /* Store current video mode     */
  46.   vga256 ();                             /* Initialize WGT system        */
  47.  
  48.   myimage = wloadpcx ("wgt1.pcx", desired); /* Load the image */
  49.   
  50.   wreadpalette (0, 255, defaultpal);    /* Store default palette */
  51.   wreadpalette (0, 255, backup_pal);    /* Store backup palette */
  52.  
  53.   wputblock (0, 0, myimage, NORMAL);    /* And show the image */
  54.  
  55.   wfade_between (0, 255, 20, defaultpal, desired);      /* Perform fade */
  56.   getch ();
  57.  
  58.   /* We now need to use backup_pal since defaultpal has been changed to
  59.      the values in "desired" */
  60.  
  61.   wtextcolor (15);                      /* Text is white */
  62.   wtexttransparent (TEXTFGBG);          /* No transparencies */
  63.  
  64.   for (ctr = 0; ctr < 64; ctr++)        /* Do fades one step at a time */
  65.   {
  66.     wgtprintf (10, 180, NULL, "Fading - step #%d", ctr);
  67.     wfade_between_once (0, 255, desired, backup_pal);   /* Perform fade */
  68.     wsetpalette (0, 255, desired);      /* Show the changes */
  69.     delay (40);                         /* Wait for a while */
  70.   }
  71.   getch ();
  72.  
  73.   wfreeblock (myimage);                 /* Deallocate the image */
  74.  
  75.   wsetmode (oldmode);                   /* Reset to text mode */
  76. }
  77.